<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">合作方余额</ui:define>
    <ui:define name="content">

        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton value="刷新数据" icon="fa fa-flash"
                                         actionListener="#{partnerBalanceBean.onRefresh}"
                                         process="@this" update="@form"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"/>

                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         actionListener="#{partnerBalanceBean.onReset}"
                                         process="@this" update="@form"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2 "
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:center;">

                                <p:outputLabel for="startTime" value="开始时间"/>
                                <p:calendar id="startTime" value="#{partnerBalanceBean.$.startTime}" pattern="yyyy-MM-dd"/>

                                <p:outputLabel for="endTime" value="结束时间"/>
                                <p:calendar id="endTime" value="#{partnerBalanceBean.$.endTime}" pattern="yyyy-MM-dd"/>

                                <p:outputLabel for="templateIdInput" value="模板ID"
                                               rendered="#{security:areAllGranted('LOAN_FAMILY_BACKSTAGE_PARTNER_BALANCE_SEARCH')}"/>
                                <p:inputText id="templateIdInput" value="#{partnerBalanceBean.$.modelId}"
                                             rendered="#{security:areAllGranted('LOAN_FAMILY_BACKSTAGE_PARTNER_BALANCE_SEARCH')}"/>

                                <p:outputLabel for="partnerNameInput" value="合作方名"
                                               rendered="#{security:areAllGranted('LOAN_FAMILY_BACKSTAGE_PARTNER_BALANCE_SEARCH')}"/>
                                <p:inputText id="partnerNameInput" value="#{partnerBalanceBean.$.partnerName}"
                                             rendered="#{security:areAllGranted('LOAN_FAMILY_BACKSTAGE_PARTNER_BALANCE_SEARCH')}"/>
                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="prepaidDataTable"
                                         style="width: 100%;text-align:center"
                                         var="record"
                                         value="#{partnerBalanceBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         selection="#{partnerBalanceBean.selectedRecords}"
                                         resizableColumns="true">
                                <p:column headerText="时间">
                                    <h:outputText value="#{record.createDate}"/>
                                </p:column>
                                <p:column headerText="模板ID">
                                    <h:outputText value="#{record.modelId}"/>
                                </p:column>
                                <p:column headerText="合作方名">
                                    <h:outputText value="#{record.partnerName}"/>
                                </p:column>
                                <p:column headerText="点击人数" style="text-align:left;">
                                    <h:outputText value="#{record.clickCount}"/>
                                </p:column>
                                <p:column headerText="消耗（元）" style="text-align:right;">
                                    <h:outputText value="#{record.consumeAmount}"/>
                                </p:column>
                                <p:column headerText="充值（元）" style="text-align:right;">
                                    <h:outputText value="#{record.rechargeBalance}"/>
                                </p:column>
                                <p:column headerText="账户余额（元）" style="text-align:right;">
                                    <h:outputText value="#{record.balance}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>